/*
 * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Unlicense OR CC0-1.0
 */
#include "nvs_flash.h"
#include "esp_netif.h"
#include "protocol_examples_common.h"
#include "esp_event.h"
#include "bsp_ws2812.h"
#include <wolfssl/ssl.h>
#include "boat_sntp.h"
#include "bsp_rng.h"
#include "demo_chainmaker.h"
#include "esp_heap_caps.h"
//extern void tcp_client(void* param);





void app_main(void)
{
    unsigned int count=0;
    
    ESP_ERROR_CHECK(nvs_flash_init());
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    
    /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
    * Read "Establishing Wi-Fi or Ethernet Connection" section in
    * examples/protocols/README.md for more information about this function.
    */
    ESP_ERROR_CHECK(example_connect());
    obtain_time();
    rng_init();
    ws2812_init();

    //xTaskCreatePinnedToCore(tcp_client, "tcp_client", 4096, NULL, 3, NULL, 1);
    
    vTaskDelay(pdMS_TO_TICKS(5000));
    demo_chainmaker_main();
    
    
    
    while(1){
        ws2812_work(count);
        count++;
        vTaskDelay(pdMS_TO_TICKS(5000));
    }

    //tcp_client();
}
